:root {
  --brand-primary: #1369e8;
  --brand-primary-dark: #0f4fb6;
  --brand-navy: #0e2e63;
  --brand-orange: #f58220;
  --bg-soft: #f4f7fb;
  --border-soft: #d9e3f0;
  --text-muted: #6c7a92;
  --shadow-soft: 0 10px 26px rgba(16, 34, 71, 0.07);
  --radius-xl: 20px;
  --radius-lg: 16px;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
  scroll-padding-bottom: 170px;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2a3d;
  background: linear-gradient(180deg, #eef4ff 0%, #f6f8fc 180px, #f6f8fc 100%);
  /*padding-bottom: 110px;  ปรับตามความสูง footer */
  padding-bottom: calc(170px + env(safe-area-inset-bottom));
}

.bg-app { background: #f6f8fc; }

/* Header */
.app-topbar {
  background: linear-gradient(135deg, var(--brand-primary) 0%, #2377f1 58%, #4d95ff 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + .75rem) 0 .8rem;
  box-shadow: 0 8px 22px rgba(19, 105, 232, 0.16);
}

.app-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-width: 0;
}

.brand-logo {
  width: 58px;
  max-width: 16vw;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.08));
}

.brand-title {
  color: #fff;
  font-size: clamp(1.05rem, 3.1vw, 1.65rem);
  font-weight: 800;
  line-height: 1.12;
  white-space: nowrap;
}

.brand-subtitle {
  color: rgba(255,255,255,.86);
  font-size: .86rem;
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.btn-topbar-outline,
.btn-topbar-light {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 12px;
  padding: .62rem .85rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.15;
}

.btn-topbar-outline {
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,.45);
}
.btn-topbar-outline:hover { background: rgba(255,255,255,.16); color: #fff; }
.btn-topbar-light {
  background: #fff;
  color: var(--brand-navy);
  border: 1px solid rgba(255,255,255,.4);
}

.admin-icon-link {
  width: 46px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  text-decoration: none;
  line-height: 1;
  border-radius: 10px;
}

.admin-icon-link:hover,
.admin-icon-link:focus {
  opacity: .9;
}

.admin-icon-img {
  width: 38px;
  height: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.22));
}

/* ===== Prefix (คำนำหน้า) ให้เล็กลง ===== */
.prefix-group {
    display: flex;
    gap: 8px;
}

.prefix-group .btn {
    flex: 1;
    padding: 8px 0;        /* เดิม ~14px  */
    font-size: 14px;       /* เดิม ~16-18px */
    border-radius: 10px;
}

/* ลด icon (ถ้ามี) */
.prefix-group .btn i {
    font-size: 14px;
    margin-right: 4px;
}

/* Layout */
.app-shell { padding-bottom: 5.8rem; }
.surface-card {
  background: #fff;
  border: 1px solid rgba(17, 60, 129, 0.06);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}
.section-card {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(20, 41, 82, .045);
}
.section-card .card-body { padding: 1rem; }
.field-card {
  background: #fff;
  border: 1px solid #e3eaf5;
  border-radius: 16px;
  padding: .9rem;
  box-shadow: 0 5px 14px rgba(17, 60, 129, 0.035);
}

/* Stepper compact */
.stepper-wrap {
  background: rgba(255,255,255,.88);
  border-radius: 18px;
  padding: .7rem .55rem;
  border: 1px solid #e5ecf7;
  box-shadow: var(--shadow-soft);
}
.stepper {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .28rem;
}
.step-indicator {
  background: transparent;
  border: 0;
  border-radius: 14px;
  padding: .35rem .15rem;
  text-align: center;
  transition: .2s ease;
  cursor: pointer;
}
.step-indicator-number {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #edf2fa;
  color: #5d6d86;
  font-size: .9rem;
  font-weight: 800;
  margin-bottom: .25rem;
}
.step-indicator-label {
  display: block;
  color: #34445f;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.18;
}
.step-indicator.is-active {
  background: rgba(19,105,232,.06);
}
.step-indicator.is-active .step-indicator-number,
.step-indicator.is-complete .step-indicator-number {
  background: var(--brand-primary);
  color: #fff;
}

.step-heading {
  font-size: clamp(1.28rem, 4.3vw, 1.8rem);
  font-weight: 800;
  color: var(--brand-navy);
  margin-bottom: .15rem;
}
.step-subheading {
  color: var(--text-muted);
  margin-bottom: .85rem;
  font-size: .95rem;
  line-height: 1.45;
}
.form-label {
  font-weight: 750;
  color: #25344d;
  margin-bottom: .42rem;
}
.required::after { content: ' *'; color: #e04f5f; }
.form-control,
.form-select,
textarea.form-control {
  min-height: 42px;
  border-radius: 13px;
  border-color: #d8e2f0;
  padding: .6rem .8rem;
  font-size: 14px;
  box-shadow: none !important;
}

.form-control:focus,
.form-select:focus {
    border-color: #2b6cb0;
    box-shadow: 0 0 0 2px rgba(43,108,176,0.1);
}
textarea.form-control { min-height: 98px; }
.modern-select {
  position: relative;
}
.modern-select-control {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  border: 1px solid #d8e2f0;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
  color: #25344d;
  font-size: 14px;
  line-height: 1.35;
  padding: .68rem .85rem;
  text-align: left;
  box-shadow: 0 8px 18px rgba(17, 60, 129, .045);
}
.modern-select-control:hover {
  border-color: rgba(19,105,232,.5);
  background: #fff;
}
.modern-select-control:focus {
  border-color: rgba(19,105,232,.7);
  box-shadow: 0 0 0 .2rem rgba(19,105,232,.11);
  outline: 0;
}
.modern-select.is-invalid .modern-select-control {
  border-color: #e04f5f;
  box-shadow: 0 0 0 .2rem rgba(224, 79, 95, .12);
}
.modern-select-arrow {
  width: .62rem;
  height: .62rem;
  border-right: 2px solid #59708f;
  border-bottom: 2px solid #59708f;
  transform: rotate(45deg) translateY(-2px);
  flex: 0 0 auto;
  transition: transform .16s ease;
}
.modern-select.is-open .modern-select-arrow {
  transform: rotate(225deg) translate(-2px, -1px);
}
.modern-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + .4rem);
  z-index: 40;
  display: none;
  max-height: 284px;
  overflow-y: auto;
  border: 1px solid #d8e2f0;
  border-radius: 16px;
  background: #fff;
  padding: .35rem;
  box-shadow: 0 18px 36px rgba(14, 46, 99, .16);
}
.modern-select.is-open .modern-select-menu {
  display: grid;
  gap: .18rem;
}
.modern-select-option {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #26354e;
  font-size: 14px;
  line-height: 1.35;
  padding: .7rem .75rem;
  text-align: left;
}
.modern-select-option:hover,
.modern-select-option:focus {
  background: #eef5ff;
  color: var(--brand-primary-dark);
  outline: 0;
}
.modern-select-option.is-selected {
  background: #e7f0ff;
  color: var(--brand-primary-dark);
  font-weight: 750;
}
.form-text {
  color: var(--text-muted);
  font-size: .82rem;
}
.form-control:focus,
.form-select:focus {
  border-color: rgba(19,105,232,.65);
  box-shadow: 0 0 0 .2rem rgba(19,105,232,.11) !important;
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}
.chip-choice {
  border: 1.4px solid #d8e2f0;
  border-radius: 14px;
  padding: .7rem .4rem;
  background: #fff;
  font-weight: 700;
  color: #31425c;
  min-height: 44px;
}
.chip-choice:focus,
.chip-choice:hover {
  border-color: rgba(19,105,232,.65);
  background: #f4f8ff;
}
.quick-note {
  border-radius: 16px;
  background: linear-gradient(180deg, #0e2e63, #153a7b);
  color: #fff;
  padding: .9rem;
}
.info-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .8rem .9rem;
  border: 1px solid #e2eaf5;
  border-radius: 14px;
  text-decoration: none;
  color: #243654;
  font-weight: 600;
  background: #fff;
}
.info-list a:hover { background: #f7fbff; }
.summary-panel { position: sticky; top: 1rem; }
.slot-list .form-check { margin-bottom: .75rem; }
.slot-card {
  display: block;
  border: 1px solid #dbe5f2;
  border-radius: 16px;
  padding: .9rem;
  background: #fff;
  cursor: pointer;
}
.slot-card strong { color: var(--brand-navy); }
.review-grid { display: grid; gap: .65rem; }
.review-item {
  border: 1px solid #e1e9f3;
  border-radius: 14px;
  padding: .8rem .9rem;
  background: #fff;
}
.review-label { font-size: .82rem; color: #6d7b92; margin-bottom: .2rem; }
.review-value { font-weight: 700; color: #20314d; }
.helper-text { color: var(--text-muted); font-size: .86rem; }

/* Success page actions */
.success-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: .75rem;
  align-items: stretch;
}

.success-actions .btn {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .68rem .8rem;
  border-radius: 10px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

.success-action-pdf {
  grid-column: 1 / -1;
}

.success-related-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}

.success-related-link {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: .48rem;
  padding: .62rem .66rem;
  border: 1px solid #dce7f6;
  border-radius: 10px;
  background: #fff;
  color: #17345f;
  text-decoration: none;
  font-weight: 700;
  line-height: 1.16;
}

.success-related-link:hover {
  background: #f7fbff;
  color: var(--brand-blue);
  border-color: #bfd5f3;
}

.success-related-link:only-child {
  grid-column: 1 / -1;
}

.success-related-link span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.success-related-link .bi:first-child {
  flex: 0 0 auto;
  color: var(--brand-blue);
  font-size: 1.05rem;
}

.success-related-link .bi:last-child {
  flex: 0 0 auto;
  color: #71829a;
  font-size: .9rem;
}

.success-back-link {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: .28rem .75rem;
  border-radius: 999px;
  color: #52627a;
  font-weight: 700;
  text-decoration: none;
}

.success-back-link:hover {
  color: var(--brand-blue);
  background: #eef5ff;
}

@media (min-width: 768px) {
  .success-actions {
    grid-template-columns: 1fr;
  }

  .success-actions .btn {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 390px) {
  .success-actions,
  .success-related-links {
    grid-template-columns: 1fr;
  }
}

.faculty-suggestions {
  display: none;
  margin-top: .6rem;
  overflow: hidden;
  border: 1px solid #d9e3f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(16, 34, 71, .08);
}
.faculty-suggestions.is-visible {
  display: grid;
}
.faculty-suggestion-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf2f8;
  background: #fff;
  color: #20314d;
  padding: .72rem .9rem;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.faculty-suggestion-item:last-child {
  border-bottom: 0;
}
.faculty-suggestion-item:hover,
.faculty-suggestion-item:focus {
  outline: 0;
  background: #f3f7ff;
  color: var(--brand-primary-dark);
}
.small-badge {
  background: #edf5ff;
  color: var(--brand-primary-dark);
  border-radius: 999px;
  padding: .32rem .62rem;
  font-size: .78rem;
  font-weight: 700;
}

/* Submit loading overlay */
body.is-submitting-registration {
  overflow: hidden;
}

.registration-submit-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(238, 244, 255, 0.92);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .18s ease, visibility .18s ease;
}

.registration-submit-loading.is-active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.registration-submit-card {
  width: 100%;
  max-width: 360px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: #ffffff;
  border: 1px solid rgba(19, 105, 232, 0.18);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(14, 46, 99, 0.12);
}

.registration-loading-spinner {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border: 6px solid #d9e8ff;
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: registrationSpin .9s linear infinite;
}

.registration-submit-card h2 {
  margin: 0 0 8px;
  color: var(--brand-navy);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.3;
}

.registration-submit-card p {
  margin: 0 0 8px;
  color: #34445f;
  font-size: .95rem;
  line-height: 1.5;
}

.registration-submit-card small {
  display: block;
  color: var(--text-muted);
  font-size: .82rem;
  line-height: 1.45;
}

@keyframes registrationSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Bottom nav */
.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  background: rgba(255,255,255,.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid #dfe8f4;
  padding: .65rem .9rem calc(.65rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 18px rgba(18, 41, 84, .08);
}
.mobile-progress {
  height: 7px;
  background: #e8eef7;
  border-radius: 999px;
  overflow: hidden;
}
.mobile-progress-bar {
  height: 100%;
  width: 25%;
  background: linear-gradient(90deg, var(--brand-primary), #4f99ff);
  border-radius: 999px;
  transition: width .25s ease;
}
.mobile-nav .btn {
  min-height: 48px;
  padding-top: .65rem !important;
  padding-bottom: .65rem !important;
  font-weight: 700;
}

.mobile-submit-button {
  display: none;
}

/* Footer compact */
.mobile-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;

    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #e5edf7;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

.mobile-footer-spacer {
    height: calc(180px + env(safe-area-inset-bottom));
}

.mobile-footer .btn {
    height: 44px;
    font-size: 14px;
    border-radius: 10px;
}
.desktop-submit { display: none; }

@media (max-width: 991.98px) {
  .summary-panel { position: static; }
  body {
    padding-bottom: 0;
  }
  html, body {
    scroll-padding-bottom: 96px;
  }
  .app-shell {
    padding-bottom: 0;
  }
  .mobile-footer-spacer {
    height: calc(78px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 767.98px) {
  html { font-size: 15px; }
  .container { padding-left: 14px; padding-right: 14px; }
  .app-shell { padding-top: .9rem !important; }
  .app-topbar { padding-bottom: .7rem; }
  .app-topbar-inner { align-items: flex-start; }
  .brand-logo { width: 50px; max-width: 15vw; }
  .brand-title { font-size: 1.05rem; white-space: normal; }
  .brand-subtitle { font-size: .76rem; }
  .topbar-actions { gap: .38rem; }
  .btn-topbar-outline,
  .btn-topbar-light {
    border-radius: 11px;
    min-height: 42px;
    padding: .55rem .65rem;
    font-size: .9rem;
  }
  .admin-icon-link {
    width: 42px;
    min-height: 42px;
  }
  .admin-icon-img {
    width: 34px;
  }
  .stepper-wrap { border-radius: 17px; padding: .55rem .45rem; margin-bottom: .85rem !important; }
  .stepper { gap: .18rem; }
  .step-indicator { padding: .3rem .08rem; }
  .step-indicator-number { width: 27px; height: 27px; font-size: .82rem; }
  .step-indicator-label { font-size: .62rem; }
  .surface-card { border-radius: 18px; }
  .surface-card > .card-body { padding: 1.05rem !important; }
  .field-card { padding: .8rem; border-radius: 15px; margin-bottom: .7rem !important; }
  .step-heading { font-size: 1.45rem; }
  .step-subheading { font-size: .92rem; }
  .form-control,
  .form-select,
  textarea.form-control { min-height: 44px; font-size: .95rem; border-radius: 12px; }
  .choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .42rem; }
  .chip-choice { padding: .62rem .25rem; font-size: .92rem; }
  .small-badge { display: none; }
  .registration-submit-loading { padding: 18px; }
  .registration-submit-card {
    max-width: 340px;
    border-radius: 22px;
    padding: 28px 20px;
  }
  .registration-loading-spinner {
    width: 58px;
    height: 58px;
    margin-bottom: 18px;
  }
  .registration-submit-card h2 { font-size: 1.15rem; }
  .registration-submit-card p { font-size: .92rem; }
}

@media (max-width: 390px) {
  html { font-size: 14px; }
  .brand-logo { width: 44px; }
  .topbar-actions .bi { margin-right: 0 !important; }
  .btn-topbar-outline,
  .btn-topbar-light { min-height: 38px; padding: .5rem .55rem; font-size: .86rem; }
  .admin-icon-link {
    width: 38px;
    min-height: 38px;
  }
  .admin-icon-img {
    width: 31px;
  }
  .stepper-wrap { padding-right: .32rem; padding-left: .32rem; }
  .step-indicator-number { width: 25px; height: 25px; font-size: .78rem; }
  .step-indicator-label { font-size: .56rem; line-height: 1.08; }
  .registration-submit-card {
    border-radius: 20px;
    padding: 24px 18px;
  }
  .registration-loading-spinner {
    width: 52px;
    height: 52px;
    border-width: 5px;
  }
  .registration-submit-card h2 { font-size: 1.08rem; }
  .registration-submit-card p { font-size: .88rem; }
}

@media (min-width: 992px) {
  html, body { scroll-padding-bottom: 32px; }
  body { padding-bottom: 0; }
  .app-shell { padding-bottom: 2rem; }
  .mobile-nav { display: none; }
  .mobile-footer-spacer { display: none; }
  .desktop-submit { display: block; }
}

body.is-final-step .form-nav-actions {
  display: none !important;
}

@media (max-width: 991.98px) {
  body.is-final-step .desktop-submit {
    display: none !important;
  }

  body.is-final-step .mobile-nav {
    display: block;
  }

  body.is-final-step .mobile-nav-meta,
  body.is-final-step .mobile-progress,
  body.is-final-step .mobile-next-button {
    display: none !important;
  }

  body.is-final-step .mobile-submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (min-width: 992px) {
  body.is-final-step .desktop-submit {
    display: block;
  }
}

.card {
    padding: 14px; /* เดิม ~20 */
    border-radius: 14px;
}

@media (min-width: 992px) {
    .desktop-form-actions {
        width: 100%;
        margin-top: 16px !important;
    }

    .desktop-form-actions .btn {
        min-width: 120px;
        padding: 12px 24px !important;
    }
}

/* ===== Consent Page ===== */
.consent-card {
    padding: 24px;
    overflow: auto;
}

.consent-scroll-box {
    max-height: 420px;
    overflow-y: auto;
    padding: 18px;
    border: 1px solid #d8e2f0;
    border-radius: 18px;
    background: #ffffff;
    line-height: 1.75;
    color: #334155;
    font-size: 15px;
}

.consent-scroll-box p {
    margin-bottom: 16px;
}

.consent-scroll-box a {
    color: #0d6efd;
    font-weight: 600;
    text-decoration: none;
}

.consent-confirm-box {
    padding: 16px;
    border-radius: 18px;
    background: #f8fbff;
    border: 1px solid #dbeafe;
}

@media (max-width: 768px) {
    .consent-card {
        padding: 18px;
    }

    .consent-scroll-box {
        max-height: 52vh;
        padding: 14px;
        font-size: 14px;
        border-radius: 16px;
    }

    .consent-confirm-box {
        padding: 14px;
    }
}

.consent-badge {
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #eef4ff;
    color: #2b6cb0;
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 576px) {
    .consent-badge {
        font-size: 12px;
        padding: 4px 10px;
    }
}

/* ซ่อน step navigation ตอนอยู่หน้า consent */
body.is-consent-step .mobile-nav {
    display: none !important;
}

body.is-consent-step .desktop-form-actions {
    display: none !important;
}

/* ซ่อนทุก step ที่ไม่ได้ active */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
}

/* ตอนอยู่หน้า consent ให้แสดงเฉพาะ consent เท่านั้น */
body.is-consent-step .form-step:not([data-step="0"]) {
    display: none !important;
}

/* ซ่อน navigation ตอน consent */
body.is-consent-step .mobile-nav,
body.is-consent-step .desktop-form-actions {
    display: none !important;
}

.form-step {
    display: none;
}

.form-step.active {
    display: block;
}

body.is-consent-step .consent-sidebar {
    display: none !important;
}
/* =========================================================
   FINAL PATCH 20260426-5
   - Restore full UI styling
   - Improve KMCH logo clarity
   - Hide Back/Next buttons on Consent page
   - Remove extra bottom space on mobile Consent page
   ========================================================= */

/* Logo clarity on blue topbar */
.brand-logo {
  width: 86px;
  max-width: none;
  height: auto;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.92);
  padding: 4px 7px;
  border-radius: 10px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.10));
}

@media (max-width: 767.98px) {
  .brand-logo {
    width: 64px;
    max-width: none;
    padding: 3px 5px;
    border-radius: 8px;
  }
}

@media (max-width: 390px) {
  .brand-logo {
    width: 58px;
  }
}

/* Base step visibility */
.form-step {
  display: none;
}

.form-step.active {
  display: block;
}

/* Consent page mode */
body.is-consent-step {
  padding-bottom: 0 !important;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
}

body.is-consent-step .app-shell {
  padding-bottom: 0 !important;
}

/* Show only consent step while consent is active */
body.is-consent-step .form-step:not([data-step="0"]) {
  display: none !important;
}

body.is-consent-step .form-step[data-step="0"] {
  display: block !important;
}

/* Hide navigation/action buttons on first Consent page */
body.is-consent-step .mobile-nav,
body.is-consent-step .mobile-footer,
body.is-consent-step .mobile-footer-spacer,
body.is-consent-step .desktop-form-actions,
body.is-consent-step [data-prev-step],
body.is-consent-step [data-next-step] {
  display: none !important;
}

/* Hide sidebar cards on consent page */
body.is-consent-step .consent-sidebar,
body.is-consent-step aside {
  display: none !important;
}

/* Remove empty trailing space on mobile consent */
@media (max-width: 767.98px) {
  body.is-consent-step .app-shell {
    padding-top: .75rem !important;
    padding-bottom: 0 !important;
  }

  body.is-consent-step .consent-card,
  body.is-consent-step .consent-confirm-box,
  body.is-consent-step .surface-card,
  body.is-consent-step .section-card {
    margin-bottom: 0 !important;
  }

  body.is-consent-step .consent-scroll-box {
    max-height: 55vh;
  }
}

/* Consent badge alignment */
.consent-badge {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef4ff;
  color: #2b6cb0;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 576px) {
  .consent-badge {
    font-size: 12px;
    padding: 4px 10px;
  }
}

/*เพิ่ม การ scroll*/

.consent-scroll-box {
    max-height: 65vh;
    overflow-y: auto;
    padding: 18px;
    border: 1px solid #d8e2f0;
    border-radius: 18px;
    background: #fff;
    line-height: 1.75;
    color: #334155;
    font-size: 15px;
    -webkit-overflow-scrolling: touch;
}

.consent-card {
    overflow: visible !important;
}

body.is-consent-step {
    padding-bottom: 0 !important;
}

/* Consent layout refinement */
body.is-consent-step .row > .col-12.col-lg-8 {
    width: 100%;
    max-width: 980px;
    margin-right: auto;
    margin-left: auto;
}

body.is-consent-step .stepper-wrap,
body.is-consent-step .form-card.consent-card {
    width: 100%;
}

body.is-consent-step .stepper-wrap {
    margin-right: auto;
    margin-left: auto;
}

.consent-card {
    padding: clamp(16px, 2.4vw, 28px);
    border-radius: 22px;
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(216, 226, 240, .88);
    box-shadow: 0 16px 40px rgba(16, 34, 71, .08);
}

.consent-card > .d-flex:first-child {
    align-items: flex-start !important;
}

.consent-card .section-title {
    max-width: 760px;
    font-size: clamp(1.45rem, 3.2vw, 2.35rem);
    line-height: 1.2;
    margin-bottom: .35rem !important;
}

.consent-card .section-subtitle {
    font-size: clamp(.9rem, 1.8vw, 1.05rem);
    color: #52627a;
}

.consent-scroll-box {
    max-height: min(50vh, 430px);
    padding: clamp(14px, 2vw, 20px);
    border-radius: 16px;
    line-height: 1.65;
    font-size: 13.5px;
}

.consent-scroll-box p {
    margin-bottom: 12px;
}

.consent-confirm-box {
    display: grid;
    gap: 12px;
    padding: clamp(12px, 1.8vw, 16px);
    border-radius: 16px;
}

.consent-confirm-box p {
    margin-bottom: 0 !important;
    font-size: clamp(.9rem, 1.8vw, 1rem);
    line-height: 1.45;
}

.consent-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.consent-actions .btn {
    width: 100%;
    min-height: 48px;
    padding: .65rem .75rem;
    border-radius: 999px !important;
    font-size: clamp(.86rem, 2.4vw, 1rem);
    font-weight: 800;
    line-height: 1.2;
    white-space: normal;
}

@media (min-width: 768px) {
    body.is-consent-step .app-shell {
        padding-top: 2rem !important;
    }

    .consent-confirm-box {
        grid-template-columns: minmax(0, 1fr) minmax(330px, 42%);
        align-items: center;
    }
}

@media (min-width: 992px) {
    body.is-consent-step {
        overflow-y: auto;
        overscroll-behavior: auto;
    }

    body.is-consent-step .app-shell {
        padding-bottom: 3rem !important;
    }

    body.is-consent-step .consent-scroll-box {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 575.98px) {
    body.is-consent-step .app-shell {
        padding-right: 12px;
        padding-left: 12px;
    }

    body.is-consent-step .stepper-wrap {
        padding: .55rem .4rem;
        border-radius: 16px;
    }

    .consent-card > .d-flex:first-child {
        gap: .6rem !important;
        margin-bottom: .75rem !important;
    }

    .consent-card .section-title {
        font-size: 1.28rem;
    }

    .consent-badge {
        margin-top: 2px;
        font-size: 11px;
    }

    .consent-scroll-box {
        max-height: 48vh;
        font-size: 12.8px;
        line-height: 1.6;
    }

    body.is-consent-step .consent-scroll-box {
        max-height: 48vh;
    }

    .consent-actions {
        gap: 8px;
    }

    .consent-actions .btn {
        min-height: 44px;
        padding: .58rem .45rem;
    }
}

/* Five-step consent stepper */
body.is-consent-step .row > .col-12.col-lg-8 {
    max-width: 1180px;
}

body.is-consent-step .stepper {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
}

body.is-consent-step .step-indicator {
    min-width: 0;
    padding: .35rem .2rem;
}

body.is-consent-step .step-indicator-label {
    overflow-wrap: anywhere;
}

@media (min-width: 992px) {
    body.is-consent-step .stepper-wrap {
        padding: .6rem;
    }

    body.is-consent-step .stepper {
        gap: .2rem;
    }

    body.is-consent-step .step-indicator {
        border-radius: 12px;
        padding: .36rem .16rem;
    }

    body.is-consent-step .step-indicator-number {
        width: 28px;
        height: 28px;
        font-size: .82rem;
        margin-bottom: .2rem;
    }

    body.is-consent-step .step-indicator-label {
        font-size: .68rem;
        line-height: 1.12;
        white-space: nowrap;
    }
}

@media (max-width: 575.98px) {
    body.is-consent-step .stepper {
        gap: .12rem;
    }

    body.is-consent-step .step-indicator {
        border-radius: 10px;
        padding: .28rem .04rem;
    }

    body.is-consent-step .step-indicator-number {
        width: 24px;
        height: 24px;
        font-size: .72rem;
        margin-bottom: .18rem;
    }

body.is-consent-step .step-indicator-label {
        font-size: .5rem;
        line-height: 1.05;
        white-space: nowrap;
    }
}

/* Mobile keyboard comfort: keep iOS Safari from auto-zooming focused fields,
   and move the fixed action bar out of the way while typing. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (max-width: 991.98px) {
  input,
  select,
  textarea,
  .form-control,
  .form-select,
  textarea.form-control {
    font-size: 16px !important;
  }

  .modern-select-control,
  .modern-select-option {
    font-size: 16px;
  }

  .mobile-nav {
    transition: transform .18s ease, opacity .18s ease, visibility .18s ease;
    will-change: transform;
  }

  body.is-form-field-focused .mobile-nav,
  body.is-modern-select-open .mobile-nav {
    transform: translateY(110%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  body.is-modern-select-open .modern-select-menu {
    max-height: min(54vh, 360px);
  }

  body.is-form-field-focused .mobile-footer-spacer {
    height: calc(24px + env(safe-area-inset-bottom));
  }

  body.is-form-field-focused .app-shell {
    padding-bottom: 1.25rem;
  }
}

/* Download routing page */
.download-routing-page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

.download-routing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, .72fr);
  gap: 1rem;
  align-items: stretch;
}

.download-routing-card {
  overflow: hidden;
}

.download-routing-card .card-body {
  padding: clamp(1.25rem, 3vw, 2rem);
}

.download-routing-heading {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.download-routing-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-primary), #4f99ff);
  box-shadow: 0 12px 24px rgba(19, 105, 232, .18);
}

.download-routing-icon .bi {
  font-size: 1.55rem;
  line-height: 1;
}

.download-routing-title {
  margin: 0 0 .25rem;
  color: var(--brand-navy);
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 850;
  line-height: 1.18;
}

.download-routing-subtitle {
  margin: 0;
  max-width: 560px;
  color: var(--text-muted);
  font-size: .96rem;
  line-height: 1.55;
}

.download-routing-form {
  display: grid;
  gap: 1rem;
}

.download-routing-input {
  min-height: 50px;
  font-size: 1rem;
}

.download-routing-submit {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  font-weight: 800;
}

.download-routing-side {
  display: grid;
  align-content: start;
  gap: .75rem;
  padding: 1rem;
  border: 1px solid #dbe5f2;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 8px 22px rgba(20, 41, 82, .045);
}

.download-routing-side-item {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .8rem;
  border-radius: 14px;
  background: #f7fbff;
  color: #26354e;
  font-weight: 650;
  line-height: 1.45;
}

.download-routing-side-item .bi {
  flex: 0 0 auto;
  color: var(--brand-primary);
  font-size: 1.08rem;
  margin-top: .1rem;
}

.download-routing-back-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 42px;
  padding: .45rem .7rem;
  color: #52627a;
  font-weight: 750;
  text-decoration: none;
}

.download-routing-back-link:hover {
  color: var(--brand-primary-dark);
}

.download-routing-alert {
  max-width: 1080px;
  margin-right: auto;
  margin-left: auto;
}

@media (max-width: 991.98px) {
  .download-routing-layout {
    grid-template-columns: 1fr;
  }

  .download-routing-side {
    padding: .8rem;
  }
}

@media (max-width: 575.98px) {
  .app-topbar-inner {
    flex-wrap: wrap;
  }

  .brand-wrap {
    flex: 1 1 100%;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
  }

  .topbar-actions .btn {
    width: 100%;
    padding-right: .5rem;
    padding-left: .5rem;
  }

  .topbar-actions .bi {
    margin-right: .25rem !important;
  }

  .download-routing-heading {
    gap: .75rem;
  }

  .download-routing-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .download-routing-title {
    font-size: 1.35rem;
  }

  .download-routing-subtitle {
    font-size: .92rem;
  }

  .download-routing-side-item {
    padding: .72rem;
    font-size: .93rem;
  }
}
